package com.zyh.service.impl;

import com.zyh.pojo.BasicAccountPojo;
import com.zyh.service.FundPayService;
import com.zyh.util.*;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.junit.Test;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 跨行交易状态查询--状态未知交易查证请求
 *
 * @author Xuhp 2020/12/7
 */
@Service
public class FundPayServiceImpl implements FundPayService {

    //查询付款账户名称
    public Map<String, Object> checkAccountBalance(String PayerAcNO) {
        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");
        Element TxnDtEle = SysHead.addElement("TxnDt");
        Element TxnTmEle = SysHead.addElement("TxnTm");

        SvcCd.setText("300130001");
        ScnCd.setText("01");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));
        String bsnSrlNo = RandomNumber.productBsnSrNo();
        BsnSrlNo.setText(bsnSrlNo);
        String txnDt = RandomNumber.productTxnDt();
        TxnDtEle.setText(txnDt);
        String txnTm = RandomNumber.productTxnTm();
        TxnTmEle.setText(txnTm);

        Element CnlCd = AppHead.addElement("CnlCd");
        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element UsrNo = AppHead.addElement("UsrNo");

        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));
        InstNo.setText("003");
        OtltsNo.setText("10001");
        UsrNo.setText("8170004");

        Element TlrTp = LocalHead.addElement("TlrTp");
        Element AuthTlrNo = LocalHead.addElement("AuthTlrNo");
        Element OldAcctFlg = LocalHead.addElement("OldAcctFlg");

        TlrTp.setText("0");
        AuthTlrNo.setText("0000000");
        OldAcctFlg.setText("1");

        Element ProvCd = Body.addElement("ProvCd");
        Element OldAcctOfstLo = Body.addElement("OldAcctOfstLo");
        Element CstAcctNo = Body.addElement("CstAcctNo");
        Element QryFcnOptn = Body.addElement("QryFcnOptn");
        Element OptnFlg1 = Body.addElement("OptnFlg1");
        Element OptnFlg2 = Body.addElement("OptnFlg2");

        ProvCd.setText("63");
        OldAcctOfstLo.setText("29");
        CstAcctNo.setText(PayerAcNO);
        QryFcnOptn.setText("T");
        OptnFlg1.setText("0");
        OptnFlg2.setText("0");

        String data = SocketUtils.sendData(doc.asXML());
        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", bsnSrlNo);
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }

    //银联--生成银联数据--基金查询卡信息查询xml格式数据
    public Map<String, Object> queryCardInfo(String unionBankNo) {
        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");
        Element TxnDt = SysHead.addElement("TxnDt");
        Element TxnTm = SysHead.addElement("TxnTm");

        SvcCd.setText("300330002");
        ScnCd.setText("01");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));
        String bsnSrlNo = RandomNumber.productBsnSrNo();
        BsnSrlNo.setText(bsnSrlNo);
        String txnDt = RandomNumber.productTxnDt();
        TxnDt.setText(txnDt);
        String txnTm = RandomNumber.productTxnTm();
        TxnTm.setText(txnTm);

        Element CnlCd = AppHead.addElement("CnlCd");
        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element UsrNo = AppHead.addElement("UsrNo");

        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));
        InstNo.setText("003");
        OtltsNo.setText("10001");
        UsrNo.setText("8170004");

        Element BankNo = LocalHead.addElement("BankNo");

        BankNo.setText("1449");

        Element CrdNo = Body.addElement("CrdNo");
        Element VrfyPswdFlg = Body.addElement("VrfyPswdFlg");
        Element Pswd = Body.addElement("Pswd");

        CrdNo.setText(unionBankNo);
        VrfyPswdFlg.setText("0");
        Pswd.setText("");

        String data = SocketUtils.sendData(doc.asXML());
        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        if (text.containsKey("success")) {
            BasicAccountPojo info = (BasicAccountPojo) text.get("success");
            text.put("success", info);
            text.put("bsnSrlNo", bsnSrlNo);
            text.put("cardInfo", info.getOtltsCd());
        } else {
            text.put("error", data);
            text.put("bsnSrlNo", bsnSrlNo);
        }
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }

    //银联--银联数据记账--借记卡存款业务
    public Map<String, Object> unionpayDataByArgs(String Otslscd, String cardId,String amt) {
        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");
        Element TxnDt = SysHead.addElement("TxnDt");
        Element TxnTm = SysHead.addElement("TxnTm");

        SvcCd.setText("300110001");
        ScnCd.setText("01");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));

        String bsnSrlNo = RandomNumber.productBsnSrNo();
        BsnSrlNo.setText(bsnSrlNo);
        String txnDt = RandomNumber.productTxnDt();
        TxnDt.setText(txnDt);
        String txnTm = RandomNumber.productTxnTm();
        TxnTm.setText(txnTm);


        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element UsrNo = AppHead.addElement("UsrNo");
        Element CnlCd = AppHead.addElement("CnlCd");

        OtltsNo.setText("01000");
        UsrNo.setText("8050004");
        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));

        Element CrdAcptLoTm = LocalHead.addElement("CrdAcptLoTm");
        Element CrdAcptLoDt = LocalHead.addElement("CrdAcptLoDt");
        Element SvcPntInptMdCd = LocalHead.addElement("SvcPntInptMdCd");
        Element SvcPntCdtnCd = LocalHead.addElement("SvcPntCdtnCd");
        Element AcptInstIndCd = LocalHead.addElement("AcptInstIndCd");
        Element SndInstIdentCd = LocalHead.addElement("SndInstIdentCd");
        Element RtrvlRefrNo = LocalHead.addElement("RtrvlRefrNo");
        Element CrdAcptTmlIndCd = LocalHead.addElement("CrdAcptTmlIndCd");
        Element CrdAcptIdentCd = LocalHead.addElement("CrdAcptIdentCd");
        Element Smy = LocalHead.addElement("Smy");

        CrdAcptLoTm.setText("165141");
        CrdAcptLoDt.setText("0321");
        SvcPntInptMdCd.setText("012");
        SvcPntCdtnCd.setText("00");
        AcptInstIndCd.setText("14498500");
        SndInstIdentCd.setText("14498500");
        RtrvlRefrNo.setText("190321001179");
        CrdAcptTmlIndCd.setText("00000000");
        CrdAcptIdentCd.setText("10000000");
        Smy.setText("无卡快捷支付");
        /*Element BankNo = LocalHead.addElement("BankNo");

        BankNo.setText("003");*/

        Element MainAcctNo = Body.addElement("MainAcctNo");
        Element TxnAmt = Body.addElement("TxnAmt");
        Element MrchTp = Body.addElement("MrchTp");
        Element SvcPntPINCapCd = Body.addElement("SvcPntPINCapCd");
        Element CcyCd = Body.addElement("CcyCd");

        MainAcctNo.setText(cardId);//银联账号
        TxnAmt.setText(amt);
        MrchTp.setText("6021");
        SvcPntPINCapCd.setText("06");
        CcyCd.setText("156");

        String data = SocketUtils.sendData(doc.asXML());

        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", bsnSrlNo);
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }

    //核心--核心记账冲正--无折客户帐转内部帐冲正业务
    public Map<String, Object> coreAccounting(String oldBsnSrlNo, String tfrOutAcctNo, double amount, String otltsCd, String txnSrlNo, String txnDt, String txnTm) {
        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");
        Element TxnDt = SysHead.addElement("TxnDt");
        Element TxnTm = SysHead.addElement("TxnTm");

        SvcCd.setText("300140001");
        ScnCd.setText("02");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));
        BsnSrlNo.setText(oldBsnSrlNo);
        TxnDt.setText(txnDt);
        TxnTm.setText(txnTm);

        Element CnlCd = AppHead.addElement("CnlCd");
        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element UsrNo = AppHead.addElement("UsrNo");

        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));
        InstNo.setText("003");
        OtltsNo.setText("61001");
        UsrNo.setText("2140060");

        Element TlrTp = LocalHead.addElement("TlrTp");
        Element AuthTlrNo = LocalHead.addElement("AuthTlrNo");
        Element OldAcctFlg = LocalHead.addElement("OldAcctFlg");

        TlrTp.setText("");
        AuthTlrNo.setText("0000000");
        OldAcctFlg.setText("1");

        Element ProvCd = Body.addElement("ProvCd");
        Element OldAcctOfstLo = Body.addElement("OldAcctOfstLo");
        Element TfrOutAcctNo = Body.addElement("TfrOutAcctNo");
        Element Amt = Body.addElement("Amt");
        Element TfrInBGLAcctNo = Body.addElement("TfrInBGLAcctNo");
        Element DrwMd = Body.addElement("DrwMd");
        Element OrgnlTxnSrlNo = Body.addElement("OrgnlTxnSrlNo");


        ProvCd.setText("63");
        OldAcctOfstLo.setText("029");
        TfrOutAcctNo.setText(tfrOutAcctNo);
        Amt.setText(String.valueOf(amount));
        TfrInBGLAcctNo.setText("09" + otltsCd + "0013040002");
        DrwMd.setText("4");
        OrgnlTxnSrlNo.setText(txnSrlNo);

        String data = SocketUtils.sendData(doc.asXML());
        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", oldBsnSrlNo);
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }

    //核心--核心记账-无折客户帐转内部帐业务
    public Map<String, Object> chargeToAccount(String tfrOutAcctNo, double amount, String otltsCd) {
        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");
        Element TxnDt = SysHead.addElement("TxnDt");
        Element TxnTm = SysHead.addElement("TxnTm");

        SvcCd.setText("300110004");
        ScnCd.setText("01");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));
        String bsnSrlNo = RandomNumber.productBsnSrNo();
        BsnSrlNo.setText(bsnSrlNo);
        String txnDt = RandomNumber.productTxnDt();
        TxnDt.setText(txnDt);
        String txnTm = RandomNumber.productTxnTm();
        TxnTm.setText(txnTm);


        Element CnlCd = AppHead.addElement("CnlCd");
        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element UsrNo = AppHead.addElement("UsrNo");

        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));
        InstNo.setText("003");
        OtltsNo.setText("61001");
        UsrNo.setText("2140060");

        Element TlrTp = LocalHead.addElement("TlrTp");
        Element AuthTlrNo = LocalHead.addElement("AuthTlrNo");
        Element OldAcctFlg = LocalHead.addElement("OldAcctFlg");

        TlrTp.setText("");
        AuthTlrNo.setText("0000000");
        OldAcctFlg.setText("1");

        Element ProvCd = Body.addElement("ProvCd");
        Element OldAcctOfstLo = Body.addElement("OldAcctOfstLo");
        Element TfrOutAcctNo = Body.addElement("TfrOutAcctNo");
        Element Amt = Body.addElement("Amt");
        Element TfrInBGLAcctNo = Body.addElement("TfrInBGLAcctNo");
        Element DrwMd = Body.addElement("DrwMd");

        ProvCd.setText("63");
        OldAcctOfstLo.setText("029");
        TfrOutAcctNo.setText(tfrOutAcctNo);
        Amt.setText(String.valueOf(amount));
        TfrInBGLAcctNo.setText("09" + otltsCd + "0013040002");
        DrwMd.setText("4");

        String data = SocketUtils.sendData(doc.asXML());
        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", bsnSrlNo);
        text.put("txnSrlNo", text.get("txnSrlNo"));
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }

    //核心--核心记账冲正--资金转账冲正业务
    public Map<String, Object> fundTransfer(String tfrOutAcctNo, String outAmt, String tfrInAcctNo, String orgnlTxnSrlNo, String txnDt, String txnTm) {
        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");
        Element TxnDt = SysHead.addElement("TxnDt");
        Element TxnTm = SysHead.addElement("TxnTm");
        Element TmlIndNo = SysHead.addElement("TmlIndNo");
        Element FileFlg = SysHead.addElement("FileFlg");
        Element MsgLen = SysHead.addElement("MsgLen");

        SvcCd.setText("300140001");
        ScnCd.setText("13");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));
        BsnSrlNo.setText(orgnlTxnSrlNo);
        TxnDt.setText(txnDt);
        TxnTm.setText(txnTm);

        Element CnlCd = AppHead.addElement("CnlCd");
        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element UsrNo = AppHead.addElement("UsrNo");

        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));
        InstNo.setText("003");
        OtltsNo.setText("11001");
        UsrNo.setText("8170003");

        Element TlrTp = LocalHead.addElement("TlrTp");
        Element AuthTlrNo = LocalHead.addElement("AuthTlrNo");
        Element OldAcctFlg = LocalHead.addElement("OldAcctFlg");

        TlrTp.setText("0");
        AuthTlrNo.setText("0000000");
        OldAcctFlg.setText("2");

        Element TfrOutAcctNo = Body.addElement("TfrOutAcctNo");
        Element TfrInAcctNo = Body.addElement("TfrInAcctNo");
        Element TfrOutAmt = Body.addElement("TfrOutAmt");
        Element TfrOutCcy = Body.addElement("TfrOutCcy");
        Element TfrInCcy = Body.addElement("TfrInCcy");
        Element ProvCd = Body.addElement("ProvCd");
        Element TfrOutVlmNo = Body.addElement("TfrOutVlmNo");
        Element TfrOutSeqNo = Body.addElement("TfrOutSeqNo");
        Element DrwMd = Body.addElement("DrwMd");
        Element VchrTp = Body.addElement("VchrTp");
        Element OrgnlTxnSrlNo = Body.addElement("OrgnlTxnSrlNo");


        TfrOutAcctNo.setText(tfrOutAcctNo);
        TfrInAcctNo.setText(tfrInAcctNo);
        TfrOutAmt.setText(outAmt);
        //TfrOutCcy.setText("CNY");
        //TfrInCcy.setText("CNY");
        ProvCd.setText("63");
        DrwMd.setText("9");
        VchrTp.setText("0901");
        OrgnlTxnSrlNo.setText(orgnlTxnSrlNo);

        String data = SocketUtils.sendData(doc.asXML());
        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", orgnlTxnSrlNo);
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }

    //核心--核心记账--资金转账业务
    public Map<String, Object> moneyTransfer(String tfrOutAcctNo, String outAmt, String tfrInAcctNo) {
        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");
        Element TxnDt = SysHead.addElement("TxnDt");
        Element TxnTm = SysHead.addElement("TxnTm");
        Element TmlIndNo = SysHead.addElement("TmlIndNo");
        Element FileFlg = SysHead.addElement("FileFlg");
        Element MsgLen = SysHead.addElement("MsgLen");

        SvcCd.setText("300110004");
        ScnCd.setText("12");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));
        String bsnSrlNo = RandomNumber.productBsnSrNo();
        BsnSrlNo.setText(bsnSrlNo);
        String txnDt = RandomNumber.productTxnDt();
        TxnDt.setText(txnDt);
        String txnTm = RandomNumber.productTxnTm();
        TxnTm.setText(txnTm);

        Element CnlCd = AppHead.addElement("CnlCd");
        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element UsrNo = AppHead.addElement("UsrNo");

        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));
        InstNo.setText("003");
        OtltsNo.setText("11001");
        UsrNo.setText("8170003");

        Element TlrTp = LocalHead.addElement("TlrTp");
        Element AuthTlrNo = LocalHead.addElement("AuthTlrNo");
        Element OldAcctFlg = LocalHead.addElement("OldAcctFlg");

        TlrTp.setText("0");
        AuthTlrNo.setText("0000000");
        OldAcctFlg.setText("2");

        Element TfrOutAcctNo = Body.addElement("TfrOutAcctNo");
        Element TfrInAcctNo = Body.addElement("TfrInAcctNo");
        Element TfrOutAmt = Body.addElement("TfrOutAmt");
        Element TfrOutCcy = Body.addElement("TfrOutCcy");
        Element TfrInCcy = Body.addElement("TfrInCcy");
        Element ProvCd = Body.addElement("ProvCd");
        Element TfrOutVlmNo = Body.addElement("TfrOutVlmNo");
        Element TfrOutSeqNo = Body.addElement("TfrOutSeqNo");
        Element DrwMd = Body.addElement("DrwMd");
        Element VchrTp = Body.addElement("VchrTp");


        TfrOutAcctNo.setText(tfrOutAcctNo);
        TfrInAcctNo.setText(tfrInAcctNo);
        TfrOutAmt.setText(outAmt);
        //TfrOutCcy.setText("CNY");
        //TfrInCcy.setText("CNY");
        ProvCd.setText("63");
        DrwMd.setText("9");
        VchrTp.setText("0901");

        String data = SocketUtils.sendData(doc.asXML());
        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", bsnSrlNo);
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }

    //超网--跨行转账--对公户跨行转出业务
    public Map<String, Object> interbankTramsfer(String pyrAcctNo, String pyrAcctNm, String pyrInstNo, String pyeEbnkSysBnkNo, String pyeAcctNo, String pyeAcctNm, String amt) {

        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");


        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");
        Element RcvSrlNo = SysHead.addElement("RcvSrlNo");
        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element TxnDt = SysHead.addElement("TxnDt");
        Element TxnTm = SysHead.addElement("TxnTm");
        Element TmIIndNo = SysHead.addElement("TmIIndNo");
        Element FileFlg = SysHead.addElement("FileFlg");


        String bsnSrlNo = RandomNumber.productBsnSrNo();
        BsnSrlNo.setText(bsnSrlNo);//全局流水号
        RcvSrlNo.setText(RandomNumber.productRcvSrlNo());//超网流水号
        SvcCd.setText("300410008");//服务代码
        ScnCd.setText("04");//场景代码
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));//消费方系统编号
        String txnDt = RandomNumber.productTxnDt();
        TxnDt.setText(txnDt);//报文发起日期
        String txnTm = RandomNumber.productTxnTm();
        TxnTm.setText(txnTm);//报文发起时间
        FileFlg.setText("0");

        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element CnlCd = AppHead.addElement("CnlCd");
        Element UsrNo = AppHead.addElement("UsrNo");


        InstNo.setText("003");//机构号
        OtltsNo.setText("11001");//网点号
        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));//渠道代码
        UsrNo.setText("8170001");//柜员号

        Element VerNo = LocalHead.addElement("VerNo");
        Element IttrMbrNo = LocalHead.addElement("IttrMbrNo");
        Element IttrAplctnCd = LocalHead.addElement("IttrAplctnCd");
        Element RcvMbrNo = LocalHead.addElement("RcvMbrNo");
        Element RcvAplctnCd = LocalHead.addElement("RcvAplctnCd");
        Element UCCdTrnsmFlg = LocalHead.addElement("UCCdTrnsmFlg");
        Element CallTp = LocalHead.addElement("CallTp");

        VerNo.setText("1.0");//版本号
        IttrMbrNo.setText("8500");//报文发起成员编号
        IttrAplctnCd.setText("WIB");//报文发起应用编号
        RcvMbrNo.setText("0000");//报文接收成员编号
        RcvAplctnCd.setText("MPS");//报文接收应用编号
        CallTp.setText("SYN");//调用模式SYN同步，ASYN异步,上送SYN

        Element EntrstTm = Body.addElement("EntrstTm");
        Element PyrAcctNo = Body.addElement("PyrAcctNo");
        Element PyrAcctNm = Body.addElement("PyrAcctNm");
        Element PyrInstNo = Body.addElement("PyrInstNo");
        Element PyeEbnkSysBnkNo = Body.addElement("PyeEbnkSysBnkNo");
        Element PyeAcctNo = Body.addElement("PyeAcctNo");
        Element PyeAcctNm = Body.addElement("PyeAcctNm");
        Element CcySymb = Body.addElement("CcySymb");
        Element TxnAmt = Body.addElement("TxnAmt");
        Element PcdFeeAmt = Body.addElement("PcdFeeAmt");
        Element BsnTpNo = Body.addElement("BsnTpNo");
        Element BsnKndNo = Body.addElement("BsnKndNo");
        Element PstcrptDsc = Body.addElement("PstcrptDsc");

        EntrstTm.setText("");//委托时间
        PyrAcctNo.setText(pyrAcctNo);//付款人账号
        PyrAcctNm.setText(pyrAcctNm);//付款人账户名称
        PyrInstNo.setText(pyrInstNo);//付款人机构号
        PyeEbnkSysBnkNo.setText(pyeEbnkSysBnkNo);//收款人网银系统行号
        PyeAcctNo.setText(pyeAcctNo);//收款人账号
        PyeAcctNm.setText(pyeAcctNm);//收款人账户名称
        CcySymb.setText("CNY");//货币符号
        TxnAmt.setText(amt);//交易金额
        PcdFeeAmt.setText("0.00");//手续费金额
        BsnTpNo.setText("C210");//业务类型编号
        BsnKndNo.setText("09001");//业务种类编号
        PstcrptDsc.setText("超网用途字段2020121801");//附言
        String data = SocketUtils.sendData(doc.asXML());
        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", bsnSrlNo);
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }

    //超网--跨行转账--大额第三方转账
    public Map<String, Object> interbankTramsferBig(String cnlSrlNo, String PyrAcctNoOrCrdNoText, String pyrAcctNm, String PyeAcctNoOrCrdNoText, String pyeAcctNm, String pyeOpnAcctBnkNo, String pyeOpnAcctBnkNm, String txnAmt, String rcvBnkNo) {
        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element TxnTm = SysHead.addElement("TxnTm");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element TxnDt = SysHead.addElement("TxnDt");

        String bsnSrlNo = RandomNumber.productBsnSrNo();
        BsnSrlNo.setText(bsnSrlNo);// UUID.randomUUID().toString()

        SvcCd.setText("300410008");
        ScnCd.setText("03");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));
        String txnDt = RandomNumber.productTxnDt();
        TxnDt.setText(txnDt);
        String txnTm = RandomNumber.productTxnTm();
        TxnTm.setText(txnTm);

        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element CnlCd = AppHead.addElement("CnlCd");
        Element UsrNo = AppHead.addElement("UsrNo");

        InstNo.setText("10001");
        OtltsNo.setText("10001");
        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));
        UsrNo.setText("2010228");

        Element TxnTp = LocalHead.addElement("TxnTp");

        TxnTp.setText("ComTfrOut");//跨行转账交易固定

        Element RmtCnl = Body.addElement("RmtCnl");
        Element CcyCd = Body.addElement("CcyCd");
        Element CnlSrlNo = Body.addElement("CnlSrlNo");
        Element BsnTpNo = Body.addElement("BsnTpNo");
        Element BsnKndNo = Body.addElement("BsnKndNo");
        Element BsnPrtyLvl = Body.addElement("BsnPrtyLvl");
        Element PyrAcctNoOrCrdNo = Body.addElement("PyrAcctNoOrCrdNo");//付款人账号或卡号
        Element PyrAcctNm = Body.addElement("PyrAcctNm");
        Element PyeAcctNoOrCrdNo = Body.addElement("PyeAcctNoOrCrdNo");
        Element PyeAcctNm = Body.addElement("PyeAcctNm");
        Element PyeOpnAcctBnkNo = Body.addElement("PyeOpnAcctBnkNo");
        Element PyeOpnAcctBnkNm = Body.addElement("PyeOpnAcctBnkNm");
        Element RcvBnkNo = Body.addElement("RcvBnkNo");//接受行号
        Element TxnAmt = Body.addElement("TxnAmt");
        Element PcdFeeClctMd = Body.addElement("PcdFeeClctMd");//接受行号
        Element PcdFeeAmt = Body.addElement("PcdFeeAmt");
        Element Rmk = Body.addElement("Rmk");

        Rmk.setText("备注空");
        RmtCnl.setText("HVPS");
        CcyCd.setText("CNY");
        CnlSrlNo.setText(cnlSrlNo);//渠道流水号    00006203
        BsnTpNo.setText("A100");
        BsnKndNo.setText("02102");
        BsnPrtyLvl.setText("1");
        PyrAcctNoOrCrdNo.setText(PyrAcctNoOrCrdNoText);
        PyrAcctNm.setText(pyrAcctNm);
        PyeAcctNoOrCrdNo.setText(PyeAcctNoOrCrdNoText);//PyeAcctNoOrCrdNoText  "28160001040010434"
        PyeAcctNm.setText(pyeAcctNm);
        PyeOpnAcctBnkNo.setText(pyeOpnAcctBnkNo); //pyeOpnAcctBnkNo 102851000026"
        PyeOpnAcctBnkNm.setText(pyeOpnAcctBnkNm); //收款人开户行 名称
        RcvBnkNo.setText(rcvBnkNo);//  "102851000026"
        TxnAmt.setText(txnAmt);
        PcdFeeClctMd.setText("2");//免收
        PcdFeeAmt.setText("1");

        String data = SocketUtils.sendData(doc.asXML());
        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", bsnSrlNo);
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }


    //超网--跨行转账--大额第三方转账- 查询行号
    public Map<String, Object> interbankTramsferLineBig(String PyeOpnAcctBnkNo) {
        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element TxnTm = SysHead.addElement("TxnTm");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element TxnDt = SysHead.addElement("TxnDt");

        String bsnSrlNo = RandomNumber.productBsnSrNo();
        BsnSrlNo.setText(bsnSrlNo);// UUID.randomUUID().toString()

        SvcCd.setText("300330002");
        ScnCd.setText("07");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));
        String txnDt = RandomNumber.productTxnDt();
        TxnDt.setText(txnDt);
        String txnTm = RandomNumber.productTxnTm();
        TxnTm.setText(txnTm);

        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element CnlCd = AppHead.addElement("CnlCd");
        Element UsrNo = AppHead.addElement("UsrNo");

        InstNo.setText("10001");
        OtltsNo.setText("10001");
        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));
        UsrNo.setText("2010228");

        Element TxnTp = LocalHead.addElement("TxnTp");

        TxnTp.setText("ComTfrOut");//跨行转账交易固定

        Element QryCntnt = Body.addElement("QryCntnt");


        QryCntnt.setText(PyeOpnAcctBnkNo);

        String data = SocketUtils.sendData(doc.asXML());
        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", bsnSrlNo);
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;

    }

    //超网--跨行转账--大额第三方转账
    public Map<String, Object> interbankTramsferBigLog(String CnlSrlNo) {

        Document doc = DocumentHelper.createDocument();
        Element service = doc.addElement("service");
        Element SysHead = service.addElement("SysHead");
        Element AppHead = service.addElement("AppHead");
        Element LocalHead = service.addElement("LocalHead");
        Element Body = service.addElement("Body");

        Element TxnTm = SysHead.addElement("TxnTm");
        Element BsnSrlNo = SysHead.addElement("BsnSrlNo");

        Element SvcCd = SysHead.addElement("SvcCd");
        Element ScnCd = SysHead.addElement("ScnCd");
        Element CnsmrSysNo = SysHead.addElement("CnsmrSysNo");
        Element TxnDt = SysHead.addElement("TxnDt");

        String bsnSrlNo = RandomNumber.productBsnSrNo();
        BsnSrlNo.setText(bsnSrlNo);// UUID.randomUUID().toString()

        SvcCd.setText("300630001");
        ScnCd.setText("01");
        CnsmrSysNo.setText(ConfigInfo.getConfigInfoByName("esb.CnsmrSysNo"));
        String txnDt = RandomNumber.productTxnDt();
        TxnDt.setText(txnDt);
        String txnTm = RandomNumber.productTxnTm();
        TxnTm.setText(txnTm);

        Element InstNo = AppHead.addElement("InstNo");
        Element OtltsNo = AppHead.addElement("OtltsNo");
        Element CnlCd = AppHead.addElement("CnlCd");
        Element UsrNo = AppHead.addElement("UsrNo");

        InstNo.setText("10001");
        OtltsNo.setText("10001");
        CnlCd.setText(ConfigInfo.getConfigInfoByName("esb.cnlCd"));
        UsrNo.setText("2010228");

        Element TxnTp = LocalHead.addElement("TxnTp");

        TxnTp.setText("ComTfrOut");//跨行转账交易固定

        Element CnlSrlNoEle = Body.addElement("CnlSrlNo");

        CnlSrlNoEle.setText(CnlSrlNo);

        String data = SocketUtils.sendData(doc.asXML());

        Map<String, Object> text = XstreamKit.getBodyFromText(data);
        text.put("bsnSrlNo", bsnSrlNo);
        text.put("txnDt", txnDt);
        text.put("txnTm", txnTm);
        text.put("esbIn", doc.asXML());
        text.put("esbOut", data);
        return text;
    }
}
